package com.tempjob.common.businesss.mongo.entity;

import com.anwen.mongo.annotation.ID;
import com.anwen.mongo.annotation.collection.CollectionField;
import com.anwen.mongo.enums.IdTypeEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tempjob.common.utils.DateUtilsEx;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

/**
 * @author hui
 * @Date 2024/12/2 21:09
 **/
@Data
@ApiModel("用户零工记录")
public class UserTempJobRecord {

    @ID(type = IdTypeEnum.OBJECT_ID)
    @CollectionField("_id")
    @ApiModelProperty("id")
    private String id;

    @CollectionField("job_id")
    @ApiModelProperty("工作id")
    private String jobId;

    @CollectionField("job_type")
    @ApiModelProperty("工作类别")
    private Integer jobType;

    @CollectionField("user_id")
    @ApiModelProperty("用户id")
    private String userId;

    @CollectionField("apply_status")
    @ApiModelProperty("工作状态：1已申请2不合适3已录用4已删除")
    private Integer applyStatus;

    @CollectionField("work_date")
    @ApiModelProperty("工作日")
    private String workDate;

    @ApiModelProperty("工作时间段开始")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8")
    @CollectionField("work_on_time")
    private Date workOnTime;

    @ApiModelProperty("工作时间段结束")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8")
    @CollectionField("work_off_time")
    private Date workOffTime;

    @CollectionField(exist = false)
    private Date dayWorkOnTime;

    @CollectionField(exist = false)
    private Date dayWorkOffTime;

    @CollectionField("apply_time")
    @ApiModelProperty("申请时间")
    private Date applyTime;

    @CollectionField("confirm_time")
    @ApiModelProperty("确认时间")
    private Date confirmTime;

    public Date getDayWorkOnTime() {
        dayWorkOnTime = new Date(DateUtilsEx.getDayStart(DateUtilsEx.parseDayByDay(workDate)).getTime() + workOnTime.getTime());
        return dayWorkOnTime;
    }

    public Date getDayWorkOffTime() {
        dayWorkOffTime = new Date(DateUtilsEx.getDayStart(DateUtilsEx.parseDayByDay(workDate)).getTime() + workOffTime.getTime());
        return dayWorkOffTime;
    }

}
